home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / GNU / emacs.inst / emacs19.idb / usr / gnu / info / elisp-10.z / elisp-10
Encoding:
GNU Info File  |  1994-08-02  |  49.5 KB  |  1,217 lines

  1. This is Info file elisp, produced by Makeinfo-1.55 from the input file
  2. elisp.texi.
  3.  
  4.    This version is newer than the second printed edition of the GNU
  5. Emacs Lisp Reference Manual.  It corresponds to Emacs Version 19.19.
  6.  
  7.    Published by the Free Software Foundation 675 Massachusetts Avenue
  8. Cambridge, MA 02139 USA
  9.  
  10.    Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  11.  
  12.    Permission is granted to make and distribute verbatim copies of this
  13. manual provided the copyright notice and this permission notice are
  14. preserved on all copies.
  15.  
  16.    Permission is granted to copy and distribute modified versions of
  17. this manual under the conditions for verbatim copying, provided that
  18. the entire resulting derived work is distributed under the terms of a
  19. permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that this permission notice may be stated in a
  24. translation approved by the Foundation.
  25.  
  26.    Permission is granted to copy and distribute modified versions of
  27. this manual under the conditions for verbatim copying, provided also
  28. that the section entitled "GNU Emacs General Public License" is included
  29. exactly as in the original, and provided that the entire resulting
  30. derived work is distributed under the terms of a permission notice
  31. identical to this one.
  32.  
  33.    Permission is granted to copy and distribute translations of this
  34. manual into another language, under the above conditions for modified
  35. versions, except that the section entitled "GNU Emacs General Public
  36. License" may be included in a translation approved by the Free Software
  37. Foundation instead of in the original English.
  38.  
  39. 
  40. File: elisp,  Node: Features,  Next: Unloading,  Prev: Repeated Loading,  Up: Loading
  41.  
  42. Features
  43. ========
  44.  
  45.    `provide' and `require' are an alternative to `autoload' for loading
  46. files automatically.  They work in terms of named "features".
  47. Autoloading is triggered by calling a specific function, but a feature
  48. is loaded the first time another program asks for it by name.
  49.  
  50.    The use of named features simplifies the task of determining whether
  51. required definitions have been defined.  A feature name is a symbol that
  52. stands for a collection of functions, variables, etc.  A program that
  53. needs the collection may ensure that they are defined by "requiring"
  54. the feature.  If the file that contains the feature has not yet been
  55. loaded, then it will be loaded (or an error will be signaled if it
  56. cannot be loaded).  The file thus loaded must "provide" the required
  57. feature or an error will be signaled.
  58.  
  59.    To require the presence of a feature, call `require' with the
  60. feature name as argument.  `require' looks in the global variable
  61. `features' to see whether the desired feature has been provided
  62. already.  If not, it loads the feature from the appropriate file.  This
  63. file should call `provide' at the top-level to add the feature to
  64. `features'.
  65.  
  66.    Features are normally named after the files they are provided in so
  67. that `require' need not be given the file name.
  68.  
  69.    For example, in `emacs/lisp/prolog.el', the definition for
  70. `run-prolog' includes the following code:
  71.  
  72.      (defun run-prolog ()
  73.        "Run an inferior Prolog process,\
  74.       input and output via buffer *prolog*."
  75.        (interactive)
  76.        (require 'comint)
  77.        (switch-to-buffer (make-comint "prolog" prolog-program-name))
  78.        (inferior-prolog-mode))
  79.  
  80. The expression `(require 'shell)' loads the file `shell.el' if it has
  81. not yet been loaded.  This ensures that `make-shell' is defined.
  82.  
  83.    The `shell.el' file contains the following top-level expression:
  84.  
  85.      (provide 'shell)
  86.  
  87. This adds `shell' to the global `features' list when the `shell' file
  88. is loaded, so that `(require 'shell)' will henceforth know that nothing
  89. needs to be done.
  90.  
  91.    When `require' is used at top-level in a file, it takes effect if
  92. you byte-compile that file (*note Byte Compilation::.).  This is in case
  93. the required package contains macros that the byte compiler must know
  94. about.
  95.  
  96.    Although top-level calls to `require' are evaluated during byte
  97. compilation, `provide' calls are not.  Therefore, you can ensure that a
  98. file of definitions is loaded before it is byte-compiled by including a
  99. `provide' followed by a `require' for the same feature, as in the
  100. following example.
  101.  
  102.      (provide 'my-feature)  ; Ignored by byte compiler,
  103.                             ;   evaluated by `load'.
  104.      (require 'my-feature)  ; Evaluated by byte compiler.
  105.  
  106.  - Function: provide FEATURE
  107.      This function announces that FEATURE is now loaded, or being
  108.      loaded, into the current Emacs session.  This means that the
  109.      facilities associated with FEATURE are or will be available for
  110.      other Lisp programs.
  111.  
  112.      The direct effect of calling `provide' is to add FEATURE to the
  113.      front of the list `features' if it is not already in the list.
  114.      The argument FEATURE must be a symbol.  `provide' returns FEATURE.
  115.  
  116.           features
  117.                => (bar bish)
  118.           
  119.           (provide 'foo)
  120.                => foo
  121.           features
  122.                => (foo bar bish)
  123.  
  124.      During autoloading, if the file is not completely loaded (due to an
  125.      error in the evaluation of the contents) any function definitions
  126.      or `provide' calls that occurred during the load are undone.
  127.      *Note Autoload::.
  128.  
  129.  - Function: require FEATURE &optional FILENAME
  130.      This function checks whether FEATURE is present in the current
  131.      Emacs session (using `(featurep FEATURE)'; see below).  If it is
  132.      not, then `require' loads FILENAME with `load'.  If FILENAME is
  133.      not supplied, then the name of the symbol FEATURE is used as the
  134.      file name to load.
  135.  
  136.      If FEATURE is not provided after the file has been loaded, Emacs
  137.      will signal the error `error' (with data `Required feature FEATURE
  138.      was not provided').
  139.  
  140.  - Function: featurep FEATURE
  141.      This function returns `t' if FEATURE has been provided in the
  142.      current Emacs session (i.e., FEATURE is a member of `features'.)
  143.  
  144.  - Variable: features
  145.      The value of this variable is a list of symbols that are the
  146.      features loaded in the current Emacs session.  Each symbol was put
  147.      in this list with a call to `provide'.  The order of the elements
  148.      in the `features' list is not significant.
  149.  
  150. 
  151. File: elisp,  Node: Unloading,  Next: Hooks for Loading,  Prev: Features,  Up: Loading
  152.  
  153. Unloading
  154. =========
  155.  
  156.    You can discard the functions and variables loaded by a library to
  157. reclaim memory for other Lisp objects.  To do this, use the function
  158. `unload-feature':
  159.  
  160.  - Command: unload-feature FEATURE
  161.      This command unloads the library that provided feature FEATURE.
  162.      It undefines all functions and variables defined with `defvar',
  163.      `defmacro', `defconst', `defsubst' and `defalias' by the library
  164.      which provided feature FEATURE.  It then restores any autoloads
  165.      associated with those symbols.
  166.  
  167.    The `unload-feature' function is written in Lisp; its actions are
  168. based on the variable `load-history'.
  169.  
  170.  - Variable: load-history
  171.      This variable's value is an alist connecting library names with the
  172.      names of functions and variables they define, the features they
  173.      provide, and the features they require.
  174.  
  175.      Each element is a list and describes one library.  The CAR of the
  176.      list is the name of the library, as a string.  The rest of the
  177.      list is composed of these kinds of objects:
  178.  
  179.         * Symbols, which were defined as functions or variables.
  180.  
  181.         * Lists of the form `(require . FEATURE)' indicating the
  182.           features that are required.
  183.  
  184.         * Lists of the form `(provide . FEATURE)' indicating the
  185.           features that are provided.
  186.  
  187.      The value of `load-history' may have one element whose CAR is
  188.      `nil'.  This element describes definitions made with `eval-buffer'
  189.      on a buffer that is not visiting a file.
  190.  
  191.    The command `eval-region' updates `load-history', but does so by
  192. adding the symbols defined to the element for the file being visited,
  193. rather than replacing that element.
  194.  
  195. 
  196. File: elisp,  Node: Hooks for Loading,  Prev: Unloading,  Up: Loading
  197.  
  198. Hooks for Loading
  199. =================
  200.  
  201.    You can ask for code to be executed if and when a particular library
  202. is loaded, by calling `eval-after-load'.
  203.  
  204.  - Function: eval-after-load LIBRARY FORM
  205.      This function arranges to evaluate FORM at the end of loading the
  206.      library LIBRARY, if and when LIBRARY is loaded.
  207.  
  208.      The library name LIBRARY must exactly match the argument of
  209.      `load'.  To get the proper results when an installed library is
  210.      found by searching `load-path', you should not include any
  211.      directory names in LIBRARY.
  212.  
  213.      An error in FORM does not undo the load, but does prevent
  214.      execution of the rest of FORM.
  215.  
  216.  - Variable: after-load-alist
  217.      An alist of expressions to evaluate if and when particular
  218.      libraries are loaded.  Each element looks like this:
  219.  
  220.           (FILENAME FORMS...)
  221.  
  222.      The function `load' checks `after-load-alist' in order to
  223.      implement `eval-after-load'.
  224.  
  225. 
  226. File: elisp,  Node: Byte Compilation,  Next: Debugging,  Prev: Loading,  Up: Top
  227.  
  228. Byte Compilation
  229. ****************
  230.  
  231.    GNU Emacs Lisp has a "compiler" that translates functions written in
  232. Lisp into a special representation called "byte-code" that can be
  233. executed more efficiently.  The compiler replaces Lisp function
  234. definitions with byte-code.  When a byte-code function is called, its
  235. definition is evaluated by the "byte-code interpreter".
  236.  
  237.    Because the byte-compiled code is evaluated by the byte-code
  238. interpreter, instead of being executed directly by the machine's
  239. hardware (as true compiled code is), byte-code is completely
  240. transportable from machine to machine without recompilation.  It is not,
  241. however, as fast as true compiled code.
  242.  
  243.    In general, any version of Emacs can run byte-compiled code produced
  244. by recent earlier versions of Emacs, but the reverse is not true.  In
  245. particular, if you compile a program with Emacs 18, you can run the
  246. compiled code in Emacs 19, but not vice versa.
  247.  
  248.    *Note Compilation Errors::, for how to investigate errors occurring
  249. in byte compilation.
  250.  
  251. * Menu:
  252.  
  253. * Compilation Functions::       Byte compilation functions.
  254. * Eval During Compile::      Code to be evaluated when you compile.
  255. * Byte-Code Objects::        The data type used for byte-compiled functions.
  256. * Disassembly::                 Disassembling byte-code; how to read byte-code.
  257.  
  258. 
  259. File: elisp,  Node: Compilation Functions,  Next: Eval During Compile,  Up: Byte Compilation
  260.  
  261. The Compilation Functions
  262. =========================
  263.  
  264.    You can byte-compile an individual function or macro definition with
  265. the `byte-compile' function.  You can compile a whole file with
  266. `byte-compile-file', or several files with `byte-recompile-directory'
  267. or `batch-byte-compile'.
  268.  
  269.    When you run the byte compiler, you may get warnings in a buffer
  270. called `*Compile-Log*'.  These report usage in your program that
  271. suggest a problem, but are not necessarily erroneous.
  272.  
  273.    Be careful when byte-compiling code that uses macros.  Macro calls
  274. are expanded when they are compiled, so the macros must already be
  275. defined for proper compilation.  For more details, see *Note Compiling
  276. Macros::.
  277.  
  278.    While byte-compiling a file, any `require' calls at top-level are
  279. executed.  One way to ensure that necessary macro definitions are
  280. available during compilation is to require the file that defines them.
  281. *Note Features::.
  282.  
  283.    A byte-compiled function is not as efficient as a primitive function
  284. written in C, but runs much faster than the version written in Lisp.
  285. For a rough comparison, consider the example below:
  286.  
  287.      (defun silly-loop (n)
  288.        "Return time before and after N iterations of a loop."
  289.        (let ((t1 (current-time-string)))
  290.          (while (> (setq n (1- n))
  291.                    0))
  292.          (list t1 (current-time-string))))
  293.      => silly-loop
  294.      
  295.      (silly-loop 100000)
  296.      => ("Thu Jan 12 20:18:38 1989"
  297.          "Thu Jan 12 20:19:29 1989")  ; 51 seconds
  298.      
  299.      (byte-compile 'silly-loop)
  300.      => [Compiled code not shown]
  301.      
  302.      (silly-loop 100000)
  303.      => ("Thu Jan 12 20:21:04 1989"
  304.          "Thu Jan 12 20:21:17 1989")  ; 13 seconds
  305.  
  306.    In this example, the interpreted code required 51 seconds to run,
  307. whereas the byte-compiled code required 13 seconds.  These results are
  308. representative, but actual results will vary greatly.
  309.  
  310.  - Function: byte-compile SYMBOL
  311.      This function byte-compiles the function definition of SYMBOL,
  312.      replacing the previous definition with the compiled one.  The
  313.      function definition of SYMBOL must be the actual code for the
  314.      function; i.e., the compiler does not follow indirection to
  315.      another symbol.  `byte-compile' does not compile macros.
  316.      `byte-compile' returns the new, compiled definition of SYMBOL.
  317.  
  318.           (defun factorial (integer)
  319.             "Compute factorial of INTEGER."
  320.             (if (= 1 integer) 1
  321.               (* integer (factorial (1- integer)))))
  322.                => factorial
  323.           
  324.           (byte-compile 'factorial)
  325.                =>
  326.           #[(integer)
  327.             "^H\301U\203^H^@\301\207\302^H\303^HS!\"\207"
  328.             [integer 1 * factorial]
  329.             4 "Compute factorial of INTEGER."]
  330.  
  331.      The result is a compiled function object.  The string it contains
  332.      is the actual byte-code; each character in it is an instruction.
  333.      The vector contains all the constants, variable names and function
  334.      names used by the function, except for certain primitives that are
  335.      coded as special instructions.
  336.  
  337.  - Command: compile-defun
  338.      This command reads the defun containing point, compiles it, and
  339.      evaluates the result.  If you use this on a defun that is actually
  340.      a function definition, the effect is to install a compiled version
  341.      of that function.
  342.  
  343.  - Command: byte-compile-file FILENAME
  344.      This function compiles a file of Lisp code named FILENAME into a
  345.      file of byte-code.  The output file's name is made by appending
  346.      `c' to the end of FILENAME.
  347.  
  348.      Compilation works by reading the input file one form at a time.
  349.      If it is a definition of a function or macro, the compiled
  350.      function or macro definition is written out.  Other forms are
  351.      batched together, then each batch is compiled, and written so that
  352.      its compiled code will be executed when the file is read.  All
  353.      comments are discarded when the input file is read.
  354.  
  355.      This command returns `t'.  When called interactively, it prompts
  356.      for the file name.
  357.  
  358.           % ls -l push*
  359.           -rw-r--r--  1 lewis     791 Oct  5 20:31 push.el
  360.           
  361.           (byte-compile-file "~/emacs/push.el")
  362.                => t
  363.           
  364.           % ls -l push*
  365.           -rw-r--r--  1 lewis     791 Oct  5 20:31 push.el
  366.           -rw-rw-rw-  1 lewis     638 Oct  8 20:25 push.elc
  367.  
  368.  - Command: byte-recompile-directory DIRECTORY FLAG
  369.      This function recompiles every `.el' file in DIRECTORY that needs
  370.      recompilation.  A file needs recompilation if a `.elc' file exists
  371.      but is older than the `.el' file.
  372.  
  373.      If a `.el' file exists, but there is no corresponding `.elc' file,
  374.      then FLAG is examined.  If it is `nil', the file is ignored.  If
  375.      it is non-`nil', the user is asked whether the file should be
  376.      compiled.
  377.  
  378.      The returned value of this command is unpredictable.
  379.  
  380.  - Function: batch-byte-compile
  381.      This function runs `byte-compile-file' on the files remaining on
  382.      the command line.  This function must be used only in a batch
  383.      execution of Emacs, as it kills Emacs on completion.  An error in
  384.      one file does not prevent processing of subsequent files.  (The
  385.      file which gets the error will not, of course, produce any
  386.      compiled code.)
  387.  
  388.           % emacs -batch -f batch-byte-compile *.el
  389.  
  390.  - Function: byte-code CODE-STRING DATA-VECTOR MAX-STACK
  391.      This function actually interprets byte-code.  A byte-compiled
  392.      function is actually defined with a body that calls `byte-code'.
  393.      Don't call this function yourself.  Only the byte compiler knows
  394.      how to generate valid calls to this function.
  395.  
  396.      In newer Emacs versions (19 and up), byte-code is usually executed
  397.      as part of a compiled function object, and only rarely as part of
  398.      a call to `byte-code'.
  399.  
  400. 
  401. File: elisp,  Node: Eval During Compile,  Next: Byte-Code Objects,  Prev: Compilation Functions,  Up: Byte Compilation
  402.  
  403. Evaluation During Compilation
  404. =============================
  405.  
  406.    These features permit you to write code to be evaluated during
  407. compilation of a program.
  408.  
  409.  - Special Form: eval-and-compile BODY
  410.      This form marks BODY to be evaluated both when you compile the
  411.      containing code and when you run it (whether compiled or not).
  412.  
  413.      You can get a similar result by putting BODY in a separate file
  414.      and referring to that file with `require'.  Using `require' is
  415.      preferable if there is a substantial amount of code to be executed
  416.      in this way.
  417.  
  418.  - Special Form: eval-when-compile BODY
  419.      This form marks BODY to be evaluated at compile time *only*.  The
  420.      result of evaluation by the compiler becomes a constant which
  421.      appears in the compiled program.  When the program is interpreted,
  422.      not compiled at all, BODY is evaluated normally.
  423.  
  424.      At top-level, this is analogous to the Common Lisp idiom
  425.      `(eval-when (compile) ...)'.  Elsewhere, the Common Lisp `#.'
  426.      reader macro (but not when interpreting) is closer to what
  427.      `eval-when-compile' does.
  428.  
  429. 
  430. File: elisp,  Node: Byte-Code Objects,  Next: Disassembly,  Prev: Eval During Compile,  Up: Byte Compilation
  431.  
  432. Byte-Code Objects
  433. =================
  434.  
  435.    Byte-compiled functions have a special data type: they are
  436. "byte-code function objects".
  437.  
  438.    Internally, a byte-code function object is much like a vector;
  439. however, the evaluator handles this data type specially when it appears
  440. as a function to be called.  The printed representation for a byte-code
  441. function object is like that for a vector, with an additional `#'
  442. before the opening `['.
  443.  
  444.    In Emacs version 18, there was no byte-code function object data
  445. type; compiled functions used the function `byte-code' to run the byte
  446. code.
  447.  
  448.    A byte-code function object must have at least four elements; there
  449. is no maximum number, but only the first six elements are actually used.
  450. They are:
  451.  
  452. ARGLIST
  453.      The list of argument symbols.
  454.  
  455. BYTE-CODE
  456.      The string containing the byte-code instructions.
  457.  
  458. CONSTANTS
  459.      The vector of constants referenced by the byte code.
  460.  
  461. STACKSIZE
  462.      The maximum stack size this function needs.
  463.  
  464. DOCSTRING
  465.      The documentation string (if any); otherwise, `nil'.  For functions
  466.      preloaded before Emacs is dumped, this is usually an integer which
  467.      is an index into the `DOC' file; use `documentation' to convert
  468.      this into a string (*note Accessing Documentation::.).
  469.  
  470. INTERACTIVE
  471.      The interactive spec (if any).  This can be a string or a Lisp
  472.      expression.  It is `nil' for a function that isn't interactive.
  473.  
  474.    Here's an example of a byte-code function object, in printed
  475. representation.  It is the definition of the command `backward-sexp'.
  476.  
  477.      #[(&optional arg)
  478.        "^H\204^F^@\301^P\302^H[!\207"
  479.        [arg 1 forward-sexp]
  480.        2
  481.        254435
  482.        "p"]
  483.  
  484.    The primitive way to create a byte-code object is with
  485. `make-byte-code':
  486.  
  487.  - Function: make-byte-code &rest ELEMENTS
  488.      This function constructs and returns a byte-code function object
  489.      with ELEMENTS as its elements.
  490.  
  491.    You should not try to come up with the elements for a byte-code
  492. function yourself, because if they are inconsistent, Emacs may crash
  493. when you call the function.  Always leave it to the byte-compiler to
  494. create these objects; it, we hope, always makes the elements consistent.
  495.  
  496.    You can access the elements of a byte-code object using `aref'; you
  497. can also use `vconcat' to create a vector with the same elements.
  498.  
  499. 
  500. File: elisp,  Node: Disassembly,  Prev: Byte-Code Objects,  Up: Byte Compilation
  501.  
  502. Disassembled Byte-Code
  503. ======================
  504.  
  505.    People do not write byte-code; that job is left to the byte compiler.
  506. But we provide a disassembler to satisfy a cat-like curiosity.  The
  507. disassembler converts the byte-compiled code into humanly readable form.
  508.  
  509.    The byte-code interpreter is implemented as a simple stack machine.
  510. Values get stored by being pushed onto the stack, and are popped off and
  511. manipulated, the results being pushed back onto the stack.  When a
  512. function returns, the top of the stack is popped and returned as the
  513. value of the function.
  514.  
  515.    In addition to the stack, values used during byte-code execution can
  516. be stored in ordinary Lisp variables.  Variable values can be pushed
  517. onto the stack, and variables can be set by popping the stack.
  518.  
  519.  - Command: disassemble OBJECT &optional STREAM
  520.      This function prints the disassembled code for OBJECT.  If STREAM
  521.      is supplied, then output goes there.  Otherwise, the disassembled
  522.      code is printed to the stream `standard-output'.  The argument
  523.      OBJECT can be a function name or a lambda expression.
  524.  
  525.      As a special exception, if this function is used interactively, it
  526.      outputs to a buffer named `*Disassemble*'.
  527.  
  528.    Here are two examples of using the `disassemble' function.  We have
  529. added explanatory comments to help you relate the byte-code to the Lisp
  530. source; these do not appear in the output of `disassemble'.  These
  531. examples show unoptimized byte-code.  Nowadays byte-code is usually
  532. optimized, but we did not want to rewrite these examples, since they
  533. still serve their purpose.
  534.  
  535.      (defun factorial (integer)
  536.        "Compute factorial of an integer."
  537.        (if (= 1 integer) 1
  538.          (* integer (factorial (1- integer)))))
  539.           => factorial
  540.      
  541.      (factorial 4)
  542.           => 24
  543.      
  544.      (disassemble 'factorial)
  545.           -| byte-code for factorial:
  546.       doc: Compute factorial of an integer.
  547.       args: (integer)
  548.      
  549.      0   constant 1              ; Push 1 onto stack.
  550.      
  551.      1   varref   integer        ; Get value of `integer'
  552.                                  ;   from the environment
  553.                                  ;   and push the value
  554.                                  ;   onto the stack.
  555.      
  556.      2   eqlsign                 ; Pop top two values off stack,
  557.                                  ;   compare them,
  558.                                  ;   and push result onto stack.
  559.      
  560.      3   goto-if-nil 10          ; Pop and test top of stack;
  561.                                  ;   if `nil', go to 10,
  562.                                  ;   else continue.
  563.      
  564.      6   constant 1              ; Push 1 onto top of stack.
  565.      
  566.      7   goto     17             ; Go to 17 (in this case, 1 will be
  567.                                  ;   returned by the function).
  568.      
  569.      10  constant *              ; Push symbol `*' onto stack.
  570.      
  571.      11  varref   integer        ; Push value of `integer' onto stack.
  572.      
  573.      12  constant factorial      ; Push `factorial' onto stack.
  574.      
  575.      13  varref   integer        ; Push value of `integer' onto stack.
  576.      
  577.      14  sub1                    ; Pop `integer', decrement value,
  578.                                  ;   push new value onto stack.
  579.      
  580.                                  ; Stack now contains:
  581.                                  ;   - decremented value of `integer'
  582.                                  ;   - `factorial'
  583.                                  ;   - value of `integer'
  584.                                  ;   - `*'
  585.      
  586.      15  call     1              ; Call function `factorial' using
  587.                                  ;   the first (i.e., the top) element
  588.                                  ;   of the stack as the argument;
  589.                                  ;   push returned value onto stack.
  590.      
  591.                                  ; Stack now contains:
  592.                                  ;   - result of result of recursive
  593.                                  ;        call to `factorial'
  594.                                  ;   - value of `integer'
  595.                                  ;   - `*'
  596.      
  597.      16  call     2              ; Using the first two
  598.                                  ;   (i.e., the top two)
  599.                                  ;   elements of the stack
  600.                                  ;   as arguments,
  601.                                  ;   call the function `*',
  602.                                  ;   pushing the result onto the stack.
  603.      
  604.      17  return                  ; Return the top element
  605.                                  ;   of the stack.
  606.           => nil
  607.  
  608.    The `silly-loop' function is somewhat more complex:
  609.  
  610.      (defun silly-loop (n)
  611.        "Return time before and after N iterations of a loop."
  612.        (let ((t1 (current-time-string)))
  613.          (while (> (setq n (1- n))
  614.                    0))
  615.          (list t1 (current-time-string))))
  616.           => silly-loop
  617.      
  618.      (disassemble 'silly-loop)
  619.           -| byte-code for silly-loop:
  620.       doc: Return time before and after N iterations of a loop.
  621.       args: (n)
  622.      
  623.      0   constant current-time-string  ; Push
  624.                                        ;   `current-time-string'
  625.                                        ;   onto top of stack.
  626.      
  627.      1   call     0              ; Call `current-time-string'
  628.                                  ;    with no argument,
  629.                                  ;    pushing result onto stack.
  630.      
  631.      2   varbind  t1             ; Pop stack and bind `t1'
  632.                                  ;   to popped value.
  633.      
  634.      3   varref   n              ; Get value of `n' from
  635.                                  ;   the environment and push
  636.                                  ;   the value onto the stack.
  637.      
  638.      4   sub1                    ; Subtract 1 from top of stack.
  639.      
  640.      5   dup                     ; Duplicate the top of the stack;
  641.                                  ;   i.e. copy the top of
  642.                                  ;   the stack and push the
  643.                                  ;   copy onto the stack.
  644.      
  645.      6   varset   n              ; Pop the top of the stack,
  646.                                  ;   and bind `n' to the value.
  647.      
  648.                                  ; In effect, the sequence `dup varset'
  649.                                  ;   copies the top of the stack
  650.                                  ;   into the value of `n'
  651.                                  ;   without popping it.
  652.      
  653.      7   constant 0              ; Push 0 onto stack.
  654.      
  655.      8   gtr                     ; Pop top two values off stack,
  656.                                  ;   test if N is greater than 0
  657.                                  ;   and push result onto stack.
  658.      
  659.      9   goto-if-nil-else-pop 17 ; Goto 17 if `n' > 0
  660.                                  ;   else pop top of stack
  661.                                  ;   and continue
  662.                                  ;   (this exits the while loop).
  663.      
  664.      12  constant nil            ; Push `nil' onto stack
  665.                                  ;   (this is the body of the loop).
  666.      
  667.      13  discard                 ; Discard result of the body
  668.                                  ;   of the loop (a while loop
  669.                                  ;   is always evaluated for
  670.                                  ;   its side effects).
  671.      
  672.      14  goto     3              ; Jump back to beginning
  673.                                  ;   of while loop.
  674.      
  675.      17  discard                 ; Discard result of while loop
  676.                                  ;   by popping top of stack.
  677.      
  678.      18  varref   t1             ; Push value of `t1' onto stack.
  679.      
  680.      19  constant current-time-string  ; Push
  681.                                        ;   `current-time-string'
  682.                                        ;   onto top of stack.
  683.      
  684.      20  call     0              ; Call `current-time-string' again.
  685.      
  686.      21  list2                   ; Pop top two elements off stack,
  687.                                  ;   create a list of them,
  688.                                  ;   and push list onto stack.
  689.      
  690.      22  unbind   1              ; Unbind `t1' in local environment.
  691.      
  692.      23  return                  ; Return value of the top of stack.
  693.      
  694.           => nil
  695.  
  696. 
  697. File: elisp,  Node: Debugging,  Next: Streams,  Prev: Byte Compilation,  Up: Top
  698.  
  699. Debugging Lisp Programs
  700. ***********************
  701.  
  702.    There are three ways to investigate a problem in an Emacs Lisp
  703. program, depending on what you are doing with the program when the
  704. problem appears.
  705.  
  706.    * If the problem occurs when you run the program, you can use the
  707.      Lisp debugger to investigate what is happening during execution.
  708.  
  709.    * If the problem is syntactic, so that Lisp cannot even read the
  710.      program, you can use the Emacs facilities for editing Lisp to
  711.      localize it.
  712.  
  713.    * If the problem occurs when trying to compile the program with the
  714.      byte compiler, you need to know how to examine the compiler's
  715.      input buffer.
  716.  
  717. * Menu:
  718.  
  719. * Debugger::            How the Emacs Lisp debugger is implemented.
  720. * Syntax Errors::       How to find syntax errors.
  721. * Compilation Errors::  How to find errors that show up in byte compilation.
  722. * Edebug::        A source-level Emacs Lisp debugger.
  723.  
  724.    Another useful debugging tool is a dribble file.  When a dribble file
  725. is open, Emacs copies all keyboard input characters to that file.
  726. Afterward, you can examine the file to find out what input was used.
  727. *Note Terminal Input::.
  728.  
  729.    For debugging problems in terminal descriptions, the
  730. `open-termscript' function can be useful.  *Note Terminal Output::.
  731.  
  732. 
  733. File: elisp,  Node: Debugger,  Next: Syntax Errors,  Up: Debugging
  734.  
  735. The Lisp Debugger
  736. =================
  737.  
  738.    The "Lisp debugger" provides you with the ability to suspend
  739. evaluation of a form.  While evaluation is suspended (a state that is
  740. commonly known as a "break"), you may examine the run time stack,
  741. examine the values of local or global variables, or change those values.
  742. Since a break is a recursive edit, all the usual editing facilities of
  743. Emacs are available; you can even run programs that will enter the
  744. debugger recursively.  *Note Recursive Editing::.
  745.  
  746. * Menu:
  747.  
  748. * Error Debugging::       Entering the debugger when an error happens.
  749. * Infinite Loops::      Stopping and debugging a program that doesn't exit.
  750. * Function Debugging::    Entering it when a certain function is called.
  751. * Explicit Debug::        Entering it at a certain point in the program.
  752. * Using Debugger::        What the debugger does; what you see while in it.
  753. * Debugger Commands::     Commands used while in the debugger.
  754. * Invoking the Debugger:: How to call the function `debug'.
  755. * Internals of Debugger:: Subroutines of the debugger, and global variables.
  756.  
  757. 
  758. File: elisp,  Node: Error Debugging,  Next: Infinite Loops,  Up: Debugger
  759.  
  760. Entering the Debugger on an Error
  761. ---------------------------------
  762.  
  763.    The most important time to enter the debugger is when a Lisp error
  764. happens.  This allows you to investigate the immediate causes of the
  765. error.
  766.  
  767.    However, entry to the debugger is not a normal consequence of an
  768. error.  Many commands frequently get Lisp errors when invoked in
  769. inappropriate contexts (such as `C-f' at the end of the buffer) and
  770. during ordinary editing it would be very unpleasant to enter the
  771. debugger each time this happens.  If you want errors to enter the
  772. debugger, set the variable `debug-on-error' to non-`nil'.
  773.  
  774.  - User Option: debug-on-error
  775.      This variable determines whether the debugger is called when a
  776.      error is signaled and not handled.  If `debug-on-error' is `t', all
  777.      errors call the debugger.  If it is `nil', none call the debugger.
  778.  
  779.      The value can also be a list of error conditions that should call
  780.      the debugger.  For example, if you set it to the list
  781.      `(void-variable)', then only errors about a variable that has no
  782.      value invoke the debugger.
  783.  
  784. 
  785. File: elisp,  Node: Infinite Loops,  Next: Function Debugging,  Prev: Error Debugging,  Up: Debugger
  786.  
  787. Debugging Infinite Loops
  788. ------------------------
  789.  
  790.    When a program loops infinitely and fails to return, your first
  791. problem is to stop the loop.  On most operating systems, you can do this
  792. with `C-g', which causes quit.
  793.  
  794.    Ordinary quitting gives no information about why the program was
  795. looping.  To get more information, you can set the variable
  796. `debug-on-quit' to non-`nil'.  Quitting with `C-g' is not considered an
  797. error, and `debug-on-error' has no effect on the handling of `C-g'.
  798. Contrariwise, `debug-on-quit' has no effect on errors.
  799.  
  800.    Once you have the debugger running in the middle of the infinite
  801. loop, you can proceed from the debugger using the stepping commands.
  802. If you step through the entire loop, you will probably get enough
  803. information to solve the problem.
  804.  
  805.  - User Option: debug-on-quit
  806.      This variable determines whether the debugger is called when `quit'
  807.      is signaled and not handled.  If `debug-on-quit' is non-`nil',
  808.      then the debugger is called whenever you quit (that is, type
  809.      `C-g').  If `debug-on-quit' is `nil', then the debugger is not
  810.      called when you quit.  *Note Quitting::.
  811.  
  812. 
  813. File: elisp,  Node: Function Debugging,  Next: Explicit Debug,  Prev: Infinite Loops,  Up: Debugger
  814.  
  815. Entering the Debugger on a Function Call
  816. ----------------------------------------
  817.  
  818.    To investigate a problem that happens in the middle of a program, one
  819. useful technique is to cause the debugger to be entered when a certain
  820. function is called.  You can do this to the function in which the
  821. problem occurs, and then step through the function, or you can do this
  822. to a function called shortly before the problem, step quickly over the
  823. call to that function, and then step through its caller.
  824.  
  825.  - Command: debug-on-entry FUNCTION-NAME
  826.      This function requests FUNCTION-NAME to invoke the debugger each
  827.      time it is called.  It works by inserting the form `(debug
  828.      'debug)' into the function definition as the first form.
  829.  
  830.      Any function defined as Lisp code may be set to break on entry,
  831.      regardless of whether it is interpreted code or compiled code.
  832.      Even functions that are commands may be debugged--they will enter
  833.      the debugger when called inside a function, or when called
  834.      interactively (after the reading of the arguments).  Primitive
  835.      functions (i.e., those written in C) may not be debugged.
  836.  
  837.      When `debug-on-entry' is called interactively, it prompts for
  838.      FUNCTION-NAME in the minibuffer.
  839.  
  840.      Caveat: if `debug-on-entry' is called more than once on the same
  841.      function, the second call does nothing.  If you redefine a function
  842.      after using `debug-on-entry' on it, the code to enter the debugger
  843.      is lost.
  844.  
  845.      `debug-on-entry' returns FUNCTION-NAME.
  846.  
  847.           (defun fact (n)
  848.             (if (zerop n) 1
  849.                 (* n (fact (1- n)))))
  850.                => fact
  851.           (debug-on-entry 'fact)
  852.                => fact
  853.           (fact 3)
  854.                => 6
  855.           
  856.           ------ Buffer: *Backtrace* ------
  857.           Entering:
  858.           * fact(3)
  859.             eval-region(4870 4878 t)
  860.             byte-code("...")
  861.             eval-last-sexp(nil)
  862.             (let ...)
  863.             eval-insert-last-sexp(nil)
  864.           * call-interactively(eval-insert-last-sexp)
  865.           ------ Buffer: *Backtrace* ------
  866.           
  867.           (symbol-function 'fact)
  868.                => (lambda (n)
  869.                     (debug (quote debug))
  870.                     (if (zerop n) 1 (* n (fact (1- n)))))
  871.  
  872.  - Command: cancel-debug-on-entry FUNCTION-NAME
  873.      This function undoes the effect of `debug-on-entry' on
  874.      FUNCTION-NAME.  When called interactively, it prompts for
  875.      FUNCTION-NAME in the minibuffer.
  876.  
  877.      If `cancel-debug-on-entry' is called more than once on the same
  878.      function, the second call does nothing.  `cancel-debug-on-entry'
  879.      returns FUNCTION-NAME.
  880.  
  881. 
  882. File: elisp,  Node: Explicit Debug,  Next: Using Debugger,  Prev: Function Debugging,  Up: Debugger
  883.  
  884. Explicit Entry to the Debugger
  885. ------------------------------
  886.  
  887.    You can cause the debugger to be called at a certain point in your
  888. program by writing the expression `(debug)' at that point.  To do this,
  889. visit the source file, insert the text `(debug)' at the proper place,
  890. and type `C-M-x'.  Be sure to undo this insertion before you save the
  891. file!
  892.  
  893.    The place where you insert `(debug)' must be a place where an
  894. additional form can be evaluated and its value ignored.  (If the value
  895. isn't ignored, it will alter the execution of the program!)  Usually
  896. this means inside a `progn' or an implicit `progn' (*note
  897. Sequencing::.).
  898.  
  899. 
  900. File: elisp,  Node: Using Debugger,  Next: Debugger Commands,  Prev: Explicit Debug,  Up: Debugger
  901.  
  902. Using the Debugger
  903. ------------------
  904.  
  905.    When the debugger is entered, it displays the previously selected
  906. buffer in one window and a buffer named `*Backtrace*' in another
  907. window.  The backtrace buffer contains one line for each level of Lisp
  908. function execution currently going on.  At the beginning of this buffer
  909. is a message describing the reason that the debugger was invoked (such
  910. as the error message and associated data, if it was invoked due to an
  911. error).
  912.  
  913.    The backtrace buffer is read-only and uses a special major mode,
  914. Debugger mode, in which letters are defined as debugger commands.  The
  915. usual Emacs editing commands are available; thus, you can switch windows
  916. to examine the buffer that was being edited at the time of the error,
  917. switch buffers, visit files, or do any other sort of editing.  However,
  918. the debugger is a recursive editing level (*note Recursive Editing::.)
  919. and it is wise to go back to the backtrace buffer and exit the debugger
  920. (with the `q' command) when you are finished with it.  Exiting the
  921. debugger gets out of the recursive edit and kills the backtrace buffer.
  922.  
  923.    The contents of the backtrace buffer show you the functions that are
  924. executing and the arguments that were given to them.  It also allows
  925. you to specify a stack frame by moving point to the line describing
  926. that frame.  (A stack frame is the place where the Lisp interpreter
  927. records information about a particular invocation of a function.  The
  928. frame whose line point is on is considered the "current frame".) Some
  929. of the debugger commands operate on the current frame.
  930.  
  931.    The debugger itself should always be run byte-compiled, since it
  932. makes assumptions about how many stack frames are used for the debugger
  933. itself.  These assumptions are false if the debugger is running
  934. interpreted.
  935.  
  936. 
  937. File: elisp,  Node: Debugger Commands,  Next: Invoking the Debugger,  Prev: Using Debugger,  Up: Debugger
  938.  
  939. Debugger Commands
  940. -----------------
  941.  
  942.    Inside the debugger (in Debugger mode), these special commands are
  943. available in addition to the usual cursor motion commands.  (Keep in
  944. mind that all the usual facilities of Emacs, such as switching windows
  945. or buffers, are still available.)
  946.  
  947.    The most important use of debugger commands is for stepping through
  948. code, so that you can see how control flows.  The debugger can step
  949. through the control structures of an interpreted function, but cannot do
  950. so in a byte-compiled function.  If you would like to step through a
  951. byte-compiled function, replace it with an interpreted definition of the
  952. same function.  (To do this, visit the source file for the function and
  953. type `C-M-x' on its definition.)
  954.  
  955. `c'
  956.      Exit the debugger and continue execution.  When continuing is
  957.      possible, it resumes execution of the program as if the debugger
  958.      had never been entered (aside from the effect of any variables or
  959.      data structures you may have changed while inside the debugger).
  960.  
  961.      Continuing is possible after entry to the debugger due to function
  962.      entry or exit, explicit invocation, quitting or certain errors.
  963.      Most errors cannot be continued; trying to continue an unsuitable
  964.      error causes the same error to occur again.
  965.  
  966. `d'
  967.      Continue execution, but enter the debugger the next time any Lisp
  968.      function is called.  This allows you to step through the
  969.      subexpressions of an expression, seeing what values the
  970.      subexpressions compute, and what else they do.
  971.  
  972.      The stack frame made for the function call which enters the
  973.      debugger in this way will be flagged automatically so that the
  974.      debugger will be called again when the frame is exited.  You can
  975.      use the `u' command to cancel this flag.
  976.  
  977. `b'
  978.      Flag the current frame so that the debugger will be entered when
  979.      the frame is exited.  Frames flagged in this way are marked with
  980.      stars in the backtrace buffer.
  981.  
  982. `u'
  983.      Don't enter the debugger when the current frame is exited.  This
  984.      cancels a `b' command on that frame.
  985.  
  986. `e'
  987.      Read a Lisp expression in the minibuffer, evaluate it, and print
  988.      the value in the echo area.  This is the same as the command
  989.      `M-ESC', except that `e' is not normally disabled like `M-ESC'.
  990.  
  991. `q'
  992.      Terminate the program being debugged; return to top-level Emacs
  993.      command execution.
  994.  
  995.      If the debugger was entered due to a `C-g' but you really want to
  996.      quit, and not debug, use the `q' command.
  997.  
  998. `r'
  999.      Return a value from the debugger.  The value is computed by
  1000.      reading an expression with the minibuffer and evaluating it.
  1001.  
  1002.      The `r' command makes a difference when the debugger was invoked
  1003.      due to exit from a Lisp call frame (as requested with `b'); then
  1004.      the value specified in the `r' command is used as the value of that
  1005.      frame.
  1006.  
  1007.      You can't use `r' when the debugger was entered due to an error.
  1008.  
  1009. 
  1010. File: elisp,  Node: Invoking the Debugger,  Next: Internals of Debugger,  Prev: Debugger Commands,  Up: Debugger
  1011.  
  1012. Invoking the Debugger
  1013. ---------------------
  1014.  
  1015.    Here we describe fully the function used to invoke the debugger.
  1016.  
  1017.  - Function: debug &rest DEBUGGER-ARGS
  1018.      This function enters the debugger.  It switches buffers to a buffer
  1019.      named `*Backtrace*' (or `*Backtrace*<2>' if it is the second
  1020.      recursive entry to the debugger, etc.), and fills it with
  1021.      information about the stack of Lisp function calls.  It then
  1022.      enters a recursive edit, leaving that buffer in Debugger mode and
  1023.      displayed in the selected window.
  1024.  
  1025.      Debugger mode provides a `c' command which operates by exiting the
  1026.      recursive edit, switching back to the previous buffer, and
  1027.      returning to whatever called `debug'.  The `r' command also
  1028.      returns from `debug'.  These are the only ways the function
  1029.      `debug' can return to its caller.
  1030.  
  1031.      If the first of the DEBUGGER-ARGS passed to `debug' is `nil' (or
  1032.      if it is not one of the following special values), then the rest
  1033.      of the arguments to `debug' are printed at the top of the
  1034.      `*Backtrace*' buffer.  This mechanism is used to display a message
  1035.      to the user.
  1036.  
  1037.      However, if the first argument passed to `debug' is one of the
  1038.      following special values, then it has special significance.
  1039.      Normally, these values are passed to `debug' only by the internals
  1040.      of Emacs and the debugger, and not by programmers calling `debug'.
  1041.  
  1042.      The special values are:
  1043.  
  1044.     `lambda'
  1045.           When the first argument is `lambda', the debugger displays
  1046.           `Entering:' as a line of text at the top of the buffer.  This
  1047.           means that a function is being entered when
  1048.           `debug-on-next-call' is non-`nil'.
  1049.  
  1050.     `debug'
  1051.           When the first argument is `debug', the debugger displays
  1052.           `Entering:' just as in the `lambda' case.  However, `debug'
  1053.           as the argument indicates that the reason for entering the
  1054.           debugger is that a function set to debug on entry is being
  1055.           entered.
  1056.  
  1057.           In addition, `debug' as the first argument directs the
  1058.           debugger to mark the function that called `debug' so that it
  1059.           will invoke the debugger when exited.  (When `lambda' is the
  1060.           first argument, the debugger does not do this, because it has
  1061.           already been done by the interpreter.)
  1062.  
  1063.     `t'
  1064.           When the first argument is `t', the debugger displays the
  1065.           following as the top line in the buffer:
  1066.  
  1067.                Beginning evaluation of function call form:
  1068.  
  1069.           This indicates that it was entered due to the evaluation of a
  1070.           list form at a time when `debug-on-next-call' is non-`nil'.
  1071.  
  1072.     `exit'
  1073.           When the first argument is `exit', it indicates the exit of a
  1074.           stack frame previously marked to invoke the debugger on exit.
  1075.           The second argument given to `debug' in this case is the
  1076.           value being returned from the frame.  The debugger displays
  1077.           `Return value:' on the top line of the buffer, followed by
  1078.           the value being returned.
  1079.  
  1080.     `error'
  1081.           When the first argument is `error', the debugger indicates
  1082.           that it is being entered because an error or `quit' was
  1083.           signaled and not handled, by displaying `Signaling:' followed
  1084.           by the error signaled and any arguments to `signal'.  For
  1085.           example,
  1086.  
  1087.                (let ((debug-on-error t))
  1088.                     (/ 1 0))
  1089.                
  1090.                ------ Buffer: *Backtrace* ------
  1091.                Signaling: (arith-error)
  1092.                  /(1 0)
  1093.                ...
  1094.                ------ Buffer: *Backtrace* ------
  1095.  
  1096.           If an error was signaled, presumably the variable
  1097.           `debug-on-error' is non-`nil'.  If `quit' was signaled, then
  1098.           presumably the variable `debug-on-quit' is non-`nil'.
  1099.  
  1100.     `nil'
  1101.           Use `nil' as the first of the DEBUGGER-ARGS when you want to
  1102.           enter the debugger explicitly.  The rest of the DEBUGGER-ARGS
  1103.           are printed on the top line of the buffer.  You can use this
  1104.           feature to display messages--for example, to remind yourself
  1105.           of the conditions under which `debug' is called.
  1106.  
  1107. 
  1108. File: elisp,  Node: Internals of Debugger,  Prev: Invoking the Debugger,  Up: Debugger
  1109.  
  1110. Internals of the Debugger
  1111. -------------------------
  1112.  
  1113.    This section describes functions and variables used internally by the
  1114. debugger.
  1115.  
  1116.  - Variable: debugger
  1117.      The value of this variable is the function to call to invoke the
  1118.      debugger.  Its value must be a function of any number of arguments
  1119.      (or, more typically, the name of a function).  Presumably this
  1120.      function will enter some kind of debugger.  The default value of
  1121.      the variable is `debug'.
  1122.  
  1123.      The first argument that Lisp hands to the function indicates why it
  1124.      was called.  The convention for arguments is detailed in the
  1125.      description of `debug'.
  1126.  
  1127.  - Command: backtrace
  1128.      This function prints a trace of Lisp function calls currently
  1129.      active.  This is the function used by `debug' to fill up the
  1130.      `*Backtrace*' buffer.  It is written in C, since it must have
  1131.      access to the stack to determine which function calls are active.
  1132.      The return value is always `nil'.
  1133.  
  1134.      In the following example, `backtrace' is called explicitly in a
  1135.      Lisp expression.  When the expression is evaluated, the backtrace
  1136.      is printed to the stream `standard-output': in this case, to the
  1137.      buffer `backtrace-output'.  Each line of the backtrace represents
  1138.      one function call.  If the arguments of the function call are all
  1139.      known, they are displayed; if they are being computed, that fact
  1140.      is stated.  The arguments of special forms are elided.
  1141.  
  1142.           (with-output-to-temp-buffer "backtrace-output"
  1143.             (let ((var 1))
  1144.               (save-excursion
  1145.                 (setq var (eval '(progn
  1146.                                    (1+ var)
  1147.                                    (list 'testing (backtrace))))))))
  1148.           
  1149.                => nil
  1150.  
  1151.           ----------- Buffer: backtrace-output ------------
  1152.             backtrace()
  1153.             (list ...computing arguments...)
  1154.             (progn ...)
  1155.             eval((progn (1+ var) (list (quote testing) (backtrace))))
  1156.             (setq ...)
  1157.             (save-excursion ...)
  1158.             (let ...)
  1159.             (with-output-to-temp-buffer ...)
  1160.             eval-region(1973 2142 #<buffer *scratch*>)
  1161.             byte-code("...  for eval-print-last-sexp ...")
  1162.             eval-print-last-sexp(nil)
  1163.           * call-interactively(eval-print-last-sexp)
  1164.           ----------- Buffer: backtrace-output ------------
  1165.  
  1166.      The character `*' indicates a frame whose debug-on-exit flag is
  1167.      set.
  1168.  
  1169.  - Variable: debug-on-next-call
  1170.      This variable determines whether the debugger is called before the
  1171.      next `eval', `apply' or `funcall'.  It is automatically reset to
  1172.      `nil' when the debugger is entered.
  1173.  
  1174.      The `d' command in the debugger works by setting this variable.
  1175.  
  1176.  - Function: backtrace-debug LEVEL FLAG
  1177.      This function sets the debug-on-exit flag of the eval frame LEVEL
  1178.      levels down to FLAG.  If FLAG is non-`nil', this will cause the
  1179.      debugger to be entered when that frame exits.  Even a nonlocal
  1180.      exit through that frame will enter the debugger.
  1181.  
  1182.      The debug-on-exit flag is an entry in the stack frame of a
  1183.      function call.  This flag is examined on every exit from a
  1184.      function.
  1185.  
  1186.      Normally, this function is only called by the debugger.
  1187.  
  1188.  - Variable: command-debug-status
  1189.      This variable records the debugging status of current interactive
  1190.      command.  Each time a command is called interactively, this
  1191.      variable is bound to `nil'.  The debugger can set this variable to
  1192.      leave information for future debugger invocations during the same
  1193.      command.
  1194.  
  1195.      The advantage of using this variable rather that defining another
  1196.      global variable is that the data will never carry over to a later
  1197.      other command invocation.
  1198.  
  1199.  - Function: backtrace-frame FRAME-NUMBER
  1200.      The function `backtrace-frame' is intended for use in Lisp
  1201.      debuggers.  It returns information about what computation is
  1202.      happening in the eval frame LEVEL levels down.
  1203.  
  1204.      If that frame has not evaluated the arguments yet (or is a special
  1205.      form), the value is `(nil FUNCTION ARG-FORMS...)'.
  1206.  
  1207.      If that frame has evaluated its arguments and called its function
  1208.      already, the value is `(t FUNCTION ARG-VALUES...)'.
  1209.  
  1210.      In the return value, FUNCTION is whatever was supplied as CAR of
  1211.      evaluated list, or a `lambda' expression in the case of a macro
  1212.      call.  If the function has a `&rest' argument, that is represented
  1213.      as the tail of the list ARG-VALUES.
  1214.  
  1215.      If the argument is out of range, `backtrace-frame' returns `nil'.
  1216.  
  1217.